package com.syt.sms.receiver;

import com.rabbitmq.client.AMQP;
import com.syt.rabbitmq.constant.MqConst;
import com.syt.sms.service.SMSService;
import com.syt.vo.msm.MsmVo;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author: xxx
 * @Date: 2023/2/27 19:46
 * @Description: rabbitmq 监听器
 */
@Component
public class SmsReceiver {

    @Autowired
    private SMSService smsService;


    @RabbitListener(bindings = @QueueBinding(value = @Queue(value = MqConst.QUEUE_SMS_ITEM,durable = "true"),exchange = @Exchange(value =MqConst.EXCHANGE_DIRECT_SMS),key = {MqConst.QUEUE_SMS_ITEM}))
    public void setSmsReceiver(MsmVo msmVo, Message message, AMQP.Channel channel) {
        smsService.sendPhoneCode(msmVo);
    }



}
